package com.mycat.rpc;

import java.net.InetSocketAddress;

/**
 * RPC测试
 *
 * @author roger.
 * @email 190642964@qq.com
 * @create 2017-02-10
 */
public class RpcTest {

    public static void main(String[] args) {

        RpcImporter<EchoService> importe = new RpcImporter<>();
        EchoService service = importe.importer(EchoServiceImpl.class, new InetSocketAddress("localhost", 8088));


        for (int i = 0; i < 100; i++) {
            new Thread(new RpcClient(service, i)).start();

        }
    }

    private static class RpcClient implements Runnable {

        private EchoService service;
        private int i;

        public RpcClient(EchoService service, int i) {
            this.service = service;
            this.i = i;
        }

        @Override
        public void run() {
            System.out.println(service.echo("Are you ok " + i + " ?"));
        }
    }

}
